﻿using HK.Core.Common.Data;
using HK.Core.Serializable.Protocol.Data;
using HK.Editor.GUIEx.Protocol.Data;
using HK.Editor.GUIEx.Protocol.Drag;
using UnityEngine;

namespace HK.Editor.GUIEx.Protocol.Window
{
    
    /// <summary>
    /// 接口 : 窗口
    /// </summary>
    public interface IWindow
    {
        
        /// <summary>
        /// 初始化标志位
        /// </summary>
        bool Initialized { get; }
        
        /// <summary>
        /// 校验码
        /// </summary>
        string CheckCode { get; }
        
        /// <summary>
        /// 数据目录
        /// </summary>
        string DataDir { get; }
        
        /// <summary>
        /// 需要刷新标志位
        /// </summary>
        bool NeedRefresh { get; }
        
#region Options
        
        /// <summary>
        /// 展开缩进
        /// </summary>
        bool Expandable { get; }
        
        /// <summary>
        /// 可拖拽
        /// </summary>
        bool Draggable { get; }

        /// <summary>
        /// 可排序
        /// </summary>
        bool Sortable { get; }

        /// <summary>
        /// 可分页
        /// </summary>
        bool Pageable { get; }

        /// <summary>
        /// 可追加
        /// </summary>
        bool Addable { get; }

        /// <summary>
        /// 可移除
        /// </summary>
        bool Removable { get; }

        /// <summary>
        /// 可编辑
        /// </summary>
        bool Editable { get; }

        /// <summary>
        /// 可检索
        /// </summary>
        bool Searchable { get; }

        /// <summary>
        /// 可导入
        /// </summary>
        bool Importable { get; }

        /// <summary>
        /// 可导出
        /// </summary>
        bool Exportable { get; }

        /// <summary>
        /// 可清楚
        /// </summary>
        bool Clearable { get; }
        
        /// <summary>
        /// 可帮助的
        /// <para>* 窗体右上角，工具栏处有帮助按钮</para>
        /// </summary>
        bool Helpful { get; }

#endregion

#region Position&Size

        /// <summary>
        /// 窗体显示区域
        /// </summary>
        Rect DisplayRect { get; }
        
        /// <summary>
        /// 位置
        /// </summary>
        Vector2 Pos { get; }
        
        /// <summary>
        /// 窗体宽度
        /// </summary>
        float Width { get; }
        
        /// <summary>
        /// 窗体高度
        /// </summary>
        float Height { get; }

#endregion

#region Window

        /// <summary>
        /// 打开
        /// </summary>
        void OpenWindow();

        /// <summary>
        /// 关闭
        /// </summary>
        void CloseWindow();

#endregion

#region Drag
        
        /// <summary>
        /// 拖拽Control Id
        /// </summary>
        int DragDropControlID { get; }

#endregion

#region Action

        /// <summary>
        /// 导入选项
        /// </summary>
        int Options { get; }

        /// <summary>
        /// 导入
        /// </summary>
        /// <returns>true:成功; false:失败;</returns>
        bool Import();

        /// <summary>
        /// 导入
        /// </summary>
        /// <param name="iOptions">导入选项</param>
        /// <returns>true:成功; false:失败;</returns>
        bool Import(int iOptions);

        /// <summary>
        /// 导出
        /// </summary>
        void Export();

        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="iOptions">导出选项</param>
        void Export(int iOptions);

        /// <summary>
        /// 清空
        /// </summary>
        /// <param name="iOptions">清空选项</param>
        void Clear(int iOptions = (int)SAssetOperateOptions.Clear);

        /// <summary>
        /// 刷新
        /// </summary>
        void Refresh();

        /// <summary>
        /// Apply
        /// </summary>
        void Apply();

#endregion

    }

    /// <summary>
    /// 接口 : 窗口
    /// </summary>
    /// <typeparam name="TConf">窗体配置类型</typeparam>
    public interface IWindow<TConf> : IWindow
    {
        
#region Conf

        /// <summary>
        /// 配置信息
        /// </summary>
        TConf Conf { get; }

        /// <summary>
        /// 重置配置信息
        /// </summary>
        /// <param name="iConf">配置信息</param>
        void ResetConf(TConf iConf);

#endregion
        
    }

    /// <summary>
    /// 接口 : 窗口
    /// </summary>
    /// <typeparam name="TConf">窗体配置类型</typeparam>
    /// <typeparam name="TData">窗体数据类型</typeparam>
    public interface IWindow<TConf, out TData> : IWindow<TConf>
        where TConf : JsonData, IWindowConf
        where TData : JsonData, IWindowData
    {

#region Data

        /// <summary>
        /// 窗体数据
        /// </summary>
        TData Data { get; }
        
#endregion
    }
}
